<template>
    <div>
        <div class="box"  v-show="status" @click="isshow" @mousewheel.prevent=""></div>
        <div class="container" ref="goods">

        <ul  @mousewheel.prevent="">
            <li class="tipBox1">
                <div class="imgBox">
                    <img :src="img_url" alt="">
                </div>
                <div class="tip1">
                    <h1>¥{{price}}</h1>
                    <p></p>
                </div>
            </li>
           <div class="jsys"> <h1>机身颜色</h1></div>
            <li class="tipBox2">
                <div v-for="(val,index) in dataList2" :key="index" class="imgBox">
                    <div><img :src="val.img_url" alt=""></div>
                     <p>{{val.goods_color}}</p>
                </div>
            </li>

            <div class="ccrl">
                <h1>存储容量</h1>
            </div>

            <li class="tipBox3">
                <span  v-for="(val,index) in dataList1" :key="index">{{val.storage}}</span>
            </li>
            <li>1</li>
            <li>1</li>
            <li>1</li>
            <li>1</li>
            <li>1</li>
            <li>1</li>
            <li>1</li>
            <li>1</li>
            <li>1</li>

        </ul>
    </div>
    <div class="buy" v-show="status1">
                <div class="but"><h1>立即购买</h1></div>
            </div>
    </div>
</template>

<script>
export default {
  data () {
    return {
      // 购物页面蒙版显示隐藏
      status: false,
      status1: false,
      img_url: '',
      price: 0,
      dataList1: [],
      dataList2: []
    }
  },
  methods: {
    isshow () {
      const fun = new Promise((resolve, reject) => {
        this.status = false
        this.status1 = false
        resolve()
      })
      fun.then(() => {
        this.$refs.goods.style.bottom = '-100%'
      })
    }
  },
  // 购物商品规格面板显示
  mounted () {
    this.$bus.$on('goods', (data) => {
      const fun = new Promise((resolve, reject) => {
        this.status = true
        this.status1 = true

        resolve(data)
      })
      fun.then((data) => {
        this.$refs.goods.style.bottom = '0'
        console.log(data)
        this.dataList1 = data.data1
        this.dataList2 = data.data2
        this.img_url = this.dataList2[0].img_url
        this.price = this.dataList1[0].goods_price
      })
    })
  }
}
</script>

<style scoped>
.box{
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    position: fixed;
    z-index: 99;
    bottom: 0;
}
.container {
    width: 100%;
    height: 28rem;
    background-color: rgb(255, 255, 255);
    z-index: 999;
    transition: all .5s;
    position: fixed;
    bottom: -100%;
   border-top-left-radius: 0.625rem;
   border-top-right-radius: 0.625rem;
   overflow: hidden;
   overflow-y: scroll;
}
.imgBox{
    width: 25%;
    height: 100px;
    float: left;
    position: relative;

}
.imgBox img{
    width: 90%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.tip1{
    width: 75%;
    height: 120px;
    float: left;

}
.tip1 h1{
    font-size: 20px;
    color: red;
    margin-top: 2rem;
}
.tip1 p{
   font-size: 16px;
}
.jsys{
    width: 100%;
    line-height: 2rem;
}
.jsys h1{
    font-size: 18px;
    color: black;
    margin: 10px;
}
.tipBox2{
    width: 100%;
    height: 8.5rem;
    float: left;
}
.tipBox2 .imgBox{
    width: 20%;
    height: 100px;
    float: left;
    border: 1px solid rgb(177, 175, 175);
    margin-left: 5px;
    border-radius: 10px;
}
.tipBox2 .imgBox img{
    width: 100%;
    height: 70px;
}
.tipBox2 .imgBox p{
    width: 97%;
    height: 20px;
    background-color: aliceblue;
    color: black;
    text-align: center;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
}
.ccrl h1{
    font-size: 18px;
    color: black;
    margin: 10px;
}
.tipBox3 span{
    width: 30px;
    line-height: 30px;
    text-align: center;
    display: inline-table;
    background-color: rgb(203, 216, 216,0.3);
    margin: 0 5px;
    padding: 0 5px;
    border-radius: 10px;
}
.buy{
    width: 100%;
    height: 3.5rem;
    position: fixed;
    bottom: 0%;
    z-index: 999;
    background-color: white;
}
.buy .but{
    width: 90%;
    line-height: 2.85rem;
    text-align: center;
    margin: 5px auto;
    background-color: rgb(255, 69, 22);
    border-radius: 2rem;
}
.but h1{
    font-size: 18px;
    font-weight: bold;
    color: white;
}
</style>
